﻿using DevExpress.XtraReports.UI;
using DXApplicationTangche.report;
using DXApplicationTangche.UC.订单一览新.客户充值;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.订单一览新.销售确认单
{
    public partial class Form销售日结账单 : DevExpress.XtraEditors.XtraForm
    {
        private List<ViewwDailySaleRechargeInfoDTO> viewwDailySaleRechargeInfoDTOs = new List<ViewwDailySaleRechargeInfoDTO>();
        public Form销售日结账单()
        {
            InitializeComponent();
        }

        private void dateTimePicker下单日期_CloseUp(object sender, EventArgs e)
        {
            //获取数据
            List<ViewwDailySaleRechargeDTO> viewwDailySaleRechargeDTOs = 销售确认Service.getViewDailySaleRechargeByOrderDate
                (this.dateTimePicker下单日期.Value.ToString("yyyy-MM-dd"));
            this.viewwDailySaleRechargeInfoDTOs.Clear();
            //数据转换
            foreach(ViewwDailySaleRechargeDTO viewwDailySaleRechargeDTO in viewwDailySaleRechargeDTOs)
            {
                this.viewwDailySaleRechargeInfoDTOs.Add(new ViewwDailySaleRechargeInfoDTO(viewwDailySaleRechargeDTO));
            }
            //数据绑定
            this.gridControl销售日结账单.DataSource = this.viewwDailySaleRechargeInfoDTOs;
            this.advBandedGridView销售日结账单.RefreshData();
            this.advBandedGridView销售日结账单.ExpandAllGroups();
        }

        private void simpleButton打印_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出Excel";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridControl销售日结账单.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
